package src;

/**
 * 数组栈
 */
public class ArrayStack<E> implements Stack<E> {
    Array<E> array;

    public ArrayStack(int capacity) {
        array = new Array<>(capacity);
    }
    public ArrayStack() {
        array = new Array<>();
    }

    @Override
    public void push(E e) {
        array.push(e);
    }

    @Override
    public E pop() {
        return array.removeLast();
    }

    @Override
    public E peek() {
        return array.getLast();
    }

    @Override
    public int getSize() {
        return array.getSize();
    }

    @Override
    public boolean isEmpyt() {
        return array.isEmpty();
    }

    public int getCapacity() {
        return array.getCapacity();
    }
    
    @Override
    public String toString(){
        StringBuffer res = new StringBuffer();
        res.append("Stack: ");
        res.append(array.toString());
        res.append("<==>");
        return res.toString();
    }
}